#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QPushButton>
#include <QLabel>
#include <QComboBox>
#include <QLineEdit>
#include <QMessageBox>
#include <QFile>
#include <QTextStream>
#include <QScrollArea>
#include "function.h"

QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
    Q_OBJECT
protected:
    void closeEvent(QCloseEvent *event);
public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();
    void initMainUI();
    void initRegUI();
    void initLoginUI();
    void initAttractionUI();
    void initPreAttrUI();
    void initCancelUI();
    void initManagerUI();

    void writeUser(QString path, QString content);
    void writeAttr(QString path, QString content);
    void readUser(QString path);
    void readAttr(QString path);
    void saveData();
private:
    Ui::MainWindow *ui;

    QString sysType;
    QString filePre;

    QVBoxLayout *mainLayout;
    QWidget *mainWidget;
    QPushButton *btnReg, *btnLogin, *btnShow, *btnPre, *btnCancel, *btnManger, *btnExit;

    QWidget *regWidget;
    QVBoxLayout *regLayout;
    QLabel *labelUser, *labelName, *labelContact, *labelID, *labelType, *labelAdmin;
    QLineEdit *editUser, *editName, *editContact, *editID;
    QComboBox *comboType, *comboAdmin;
    QPushButton *btnRegSure, *btnRegCancel;

    QWidget *loginWidget;
    QVBoxLayout *loginLayout;
    QLineEdit *editLoginUser;
    QPushButton *btnLoginSure;
    QPushButton *btnLoginCancel;

    QWidget attrWidget;
    QLabel *labelAttrName, *labelAttrDesc, *labelAttrPrice, *labelAttrPerson;
    QPushButton *btnAttrBack;

    QWidget *preAttrWidget;
    QLineEdit *preAttrUser;
    QComboBox *preAttrCom;
    QLabel *preAttrRes;
    QPushButton *preAttrBack, *preAttrSure;

    QWidget *cancelWidget;
    QLineEdit *cancelUser;
    QComboBox *cancelCom;
    QPushButton *cancelSure, *cancelBack;

    QWidget *managerWidget;
    QPushButton *managerBack;

    System *system;
public slots:
    void slotReg();
    void slotRegSure();
    void slotLogin();
    void slotBtnLoginSure();
    void slotBtnShowAttr();
    void slotBtnPreAttr();
    void slotBtnPreAttrSure();
    void slotBtnCancel();
    void slotBtnCancelSure();
    void slotBtnManager();
    void slotBtnExit();
    void slotBtnBack();
//    void slotRegCancel();
//    void slotBtnLoginCancel();
//    void slotBtnAttrBacks();
//    void slotBtnPreAttrBack();
//    void slotBtnCancelBack();
//        void slotBtnManagerBack();
};
#endif // MAINWINDOW_H
